package com.kx.my06;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 引用类型
 *
 * @Resource:
 *  来自JDK的注解，spring框架支持，默认byName，没找到再byType
 *  位置：1、在属性定义上，无需set方法，推荐使用。
 *       2、在set方法上面
 */
@Component(value = "myStudent")
public class Student {
    @Value("lisi")
    private String name;
    @Value("1001")
    private Integer id;
    @Resource
    private School school;

    public Student() {
        System.out.println("Student05无参构造");
    }

    public void setName(String name) {
        this.name = name;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", id=" + id +
                ", school=" + school +
                '}';
    }
}
